﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yto.Common.Time
{
    public static class TimeHelper
    {
        private static ITimeProvider _provider;

        public static ITimeProvider Provider
        {
            get => _provider;
            set
            {
                if (value is null)
                {
                    throw new ArgumentNullException(nameof(value), "Can't set TimeHelper.provider to null!");
                }
                _provider = value;
            }
        }

        static TimeHelper()
        {
            Provider = TimeProvider.Local;
        }

        public static DateTime Now => Provider.Now;
        public static DateTimeKind Kind => Provider.Kind;
        public static bool IsMultipleTimezone => Provider.IsMultipleTimezone;

        public static DateTime Standardize(DateTime dateTime)
        {
            return Provider.Standardize(dateTime);
        }
    }
}
